<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_search" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <a v-for="dict in s_tree_menu" @click="handleNodeClick(dict)" type='primary'>{{dict.__desc}}></a>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 搜索文件 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="文件名" prop="client_filename">
              <el-input v-model="s_search.client_filename" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="('')" type='success' size="mini"><i class='fa fa-check'></i>搜索</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 文件列表 </span>
      </div>
      <el-table :data="s_project_files">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="popProductFileVersionAdd('&CMID4='+scope.row.item_id+'')">增加版本</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="gotoPage('/xcapi/ProcessFile/DownloadFile.do?&fileid='+scope.row.item_id+''+vueparams+'')">下载</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="d_files('&CMID4='+scope.row.item_id+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="文件" prop="item_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/systemadmin/ProductFileVersion?CMID4='+scope.row.item_id+''+vueparams+'')" type='primary'>{{scope.row.client_filename}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="ProductFileVersionAddVisible" append-to-body>
      <ProductFileVersionAdd v-if="ProductFileVersionAddVisible" ref="ProductFileVersionAdd" :popparams="popparams"> </ProductFileVersionAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductFileVersionAdd from "@/views/mes/systemadmin/ProductFileVersionAdd";
  export default {
    name: 'ProductFileSearch',
    components: {
      ProductFileVersionAdd,
    },
    props: ['popparams'],
    data() {
      return {
        ProductFileVersionAddVisible: false,
        ProductFileVersionAddValue: null,
        ProductFileVersionAddDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {
          client_filename: null,
        },
        s_project_files: [],
        s_tree_menu: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/systemadmin/ProductFileSearch/productFileSearch?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      popProductFileVersionAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ProductFileVersionAddVisible = !this.ProductFileVersionAddVisible;
      },
      handleOutline(data) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/systemadmin/ProductFileSearch/s_tree_menu?' + this.vueparams,
        }).then(data => {
          this.s_tree_menu = data.s_tree_menu;
          this.s_tree_menu = this.s_tree_menu.reverse();
        })
      },
    },
  }
</script>
